inspector: Don't lie with statistics
authorMatthias Clasen <mclasen@redhat.com>
Fri, 15 Apr 2016 02:52:59 +0000 (22:52 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 15 Apr 2016 02:52:59 +0000 (22:52 -0400)
If we don't have statistics, despite GOBJECT_DEBUG being set,
explain how to fix this.

gtk/inspector/statistics.c
gtk/inspector/statistics.ui

index fe33d18f03698fadfdb12aba04ee379a52a85a9a..42b315c49d0ca09e3c6fe39308077a1e438189db 100644 (file)
@@ -26,6 +26,7 @@
 #include "gtkcellrenderertext.h"
 #include "gtkcelllayout.h"
 #include "gtksearchbar.h"
+#include "gtklabel.h"
 
 enum
 {
@@ -36,6 +37,7 @@ enum
 struct _GtkInspectorStatisticsPrivate
 {
   GtkWidget *stack;
+  GtkWidget *excuse;
   GtkTreeModel *model;
   GtkTreeView  *view;
   GtkWidget *button;
@@ -168,6 +170,12 @@ toggle_record (GtkToggleButton        *button,
 
 static gboolean
 has_instance_counts (void)
+{
+  return g_type_get_instance_count (GTK_TYPE_LABEL) > 0;
+}
+
+static gboolean
+instance_counts_enabled (void)
 {
   const gchar *string;
   guint flags = 0;
@@ -365,6 +373,8 @@ constructed (GObject *object)
     update_type_counts (sl);
   else
     {
+      if (instance_counts_enabled ())
+        gtk_label_set_text (GTK_LABEL (sl->priv->excuse), _("GLib must be configured with --enable-debug"));
       gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse");
       gtk_widget_set_sensitive (sl->priv->button, FALSE);
     }
@@ -452,6 +462,7 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2);
   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_entry);
   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_bar);
+  gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, excuse);
 
 }
 
index 82672db2d175c0a3931cd83066159c6c2e242841..b1ceefce4e348476746ea2129d6f307654eb89d4 100644 (file)
             <property name="halign">center</property>
             <property name="valign">center</property>
             <child>
-              <object class="GtkLabel">
+              <object class="GtkLabel" id="excuse">
                 <property name="visible">True</property>
                 <property name="selectable">True</property>
                 <property name="label" translatable="yes">Enable statistics with GOBJECT_DEBUG=instance-count</property>